import { userAccountLogin } from '@/api/user'
export default {
	namespaced: true,
	state: () => ({
		profile: {
			id: '',
			avatar: '',
			nickname: '',
			account: '',
			mobile: '',
			token: ''
		}
	}),

	mutations: {
		setProfile (state, payload) {
			state.profile = payload
		},

		removeProfile (state) {
			state.profile = {}
		}
	},

	actions: {
		async getProfileAction ({ commit }, formData) {
			const res = await userAccountLogin(formData)
			commit('setProfile', res)
		},

		logoutAction ({ commit }) {
			commit('removeProfile')
			commit('cart/setList', [], { root: true })
		}
	}

}
